package com.letfox.test.example;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import com.letfox.ad.dao.ADPlanDao;
import com.letfox.ad.model.ADPlan;
import com.letfox.ad.user.dao.PlanADAccountUDao;
import com.letfox.ad.user.model.PlanADAccountU;
import com.letfox.frm.dao.FRMDictionaryDao;
import com.letfox.frm.model.FRMDictionary;
import com.letfox.test.util.MyBatisUtil;
import com.letfox.user.enums.UserEnums;

/**
 * 单元测试
 */
public class AdPlanExample {

	/**
	 * 需要单元测试的时候在取消注释
	 */
	private ADPlanDao fileDao;
	private FRMDictionaryDao frmDictionaryDao;
	private PlanADAccountUDao userAdRelDao;
	
	
	
	@Test
	public void upload(){
		SqlSession session = MyBatisUtil.getSqlSession(true);
		try {
			ADPlan file = new ADPlan();
			file.setAdPlanId("ZXX44X1001");
			file.setAdPlanBudgetDaily(new BigDecimal("1"));
			file.setAdPlanName("12312");
			file.setUpdateTime(new Date());
			file.setCreateTime(new Date());
			file.setCreateBy("460101XXXXX");
			file.setUpdateBy(UserEnums.UserGender.MAN.getValue());
			file.setDel("0");
			file.setEndTime(new Date());
			file.setStartTime(new Date());
			fileDao = session.getMapper(ADPlanDao.class);
			fileDao.insert(file);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	@Test
	public void frmFile(){
		SqlSession session = MyBatisUtil.getSqlSession(true);
		try {
			FRMDictionary file = new FRMDictionary();
			file.setFrmCode("ZXX44X1001");
			file.setFrmName("sss");
			file.setFrmValue("0");
			file.setFrmType("111");
			file.setUpdateTime(new Date());
			file.setCreateTime(new Date());
			frmDictionaryDao = session.getMapper(FRMDictionaryDao.class);
			frmDictionaryDao.insert(file);		
		
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	@Test
	public void aduser(){
		SqlSession session = MyBatisUtil.getSqlSession(true);
		try {
			List<PlanADAccountU> list=new ArrayList<PlanADAccountU>();
			userAdRelDao = session.getMapper(PlanADAccountUDao.class);
			String accountId="jes";
			String startCreateTime="2018-03-26 16:41:50";
			String endCreateTime="2018-03-26 16:42:50";
			String startTime="2018-03-24 10:52:05";
			String endTime="2018-03-27 10:52:05";
			Map<String, String> map=new HashMap<String, String>();
			map.put("accountId", accountId);
			map.put("startCreateTime", startCreateTime);
			map.put("endCreateTime", endCreateTime);
			map.put("startTime", startTime);
			map.put("endTime", endTime);
			list=userAdRelDao.selectUserADLiset(map);
			for (PlanADAccountU planADAccountU : list) {
				System.out.println(planADAccountU.getStartTime());
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
  
}
